﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


using groupAnalyzer.model;
namespace groupAnalyzer
{
    public class SettingsView
    {
        private Settings settings;

        public bool EnabledUsername
        {
            get
            {
                return !this.Kerberos;
            }
        }

        public bool EnabledPassword
        {
            get
            {
                return this.SavePassword && !this.Kerberos;
            }
        }

        private bool DisableElements
        {
            get
            {
                return (this.SavePassword || !this.Kerberos);
            }
        }

        public bool SavePassword 
        {
            get
            {
                return this.settings.SavePassword;
            }
            set
            {
                this.settings.Password = "";
                this.settings.SavePassword = value;
            }
        }

        public string BaseDN
        {
            get { return this.settings.BaseDN; }
            set
            {
                this.settings.BaseDN = value;
            }

        }

        public string LdapURL
        {
            get { 
                return this.settings.LdapURL; 
            }
            set
            {
                this.settings.LdapURL = value;
            }
        }

        public string Username
        {
            get { return this.settings.Username; }
            set
            {
                this.settings.Username = value;
            }
        }

        public string Password
        {
            get { return this.settings.Password; }
            set
            {
                this.settings.Password = value;
            }
        }

        public bool Kerberos
        {
            get
            {
                return (this.settings.AuthMode == AuthModeEnum.kerberos);
            }
            set
            {
                if (value)
                {
                    this.settings.AuthMode = AuthModeEnum.kerberos;
                }
                else
                {
                    this.settings.AuthMode = AuthModeEnum.usernamePassword;
                }
            }
        }

        public SettingsView(Settings settings)
        {
            this.settings = settings;
        }
    }
}
